
package com.compuvest.admin.chart.xml;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

public class ChartReader {
    
    public ChartReader() {
    }

    public static ArrayList<ChartRecord> readChartFromXML(InputStream in) throws IOException {

	ArrayList<ChartRecord> result = null;

        SAXParserFactory factory = SAXParserFactory.newInstance();
        try {
            SAXParser parser = factory.newSAXParser();
            ParserChart handler = new ParserChart();
            parser.parse(in, handler);
            result = handler.getUserList();
        }
        catch (SAXException e) { System.out.println(e.getMessage()); }
        catch (ParserConfigurationException e2) { System.out.println(e2.getMessage()); }

        return result;
    }
}
